<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <form action="">
        <input type="text" name="username" placeholder="请输入用户名" id="username">
        <!-- 存放提示信息 -->
        <span id="usernameSpan"></span>
        <br>
        <input type="password" name="password" placeholder="请输入密码"> <br>
        <span id="passwordSpan"></span>
        <button>提交</button>
    </form>

    <script type="text/javascript" src="./axios-0.18.0.js"></script>
    <script type="text/javascript">
            document.getElementById("username").onblur=function(){
                
               let username= document.getElementById("username").value;
                axios.post("http://localhost:8080/registerServlet","username="+username)
                .then(resp=>{ 
                    if(resp.data){
                    document.getElementById("usernameSpan").innerHTML="您输入的同户名可以注册！！";
                    document.getElementById("usernameSpan").style.color="blue";
                    }else{
                    document.getElementById("usernameSpan").innerHTML="您输入的用户名不可以注册！！";
                    document.getElementById("usernameSpan").style.color="blue";
                    }
                }
                )

            }
            

    </script>


</body>
</html>